﻿using System;
using System.Linq;
using System.Reflection;

namespace DemoDataGridToolBar
{
  public class LocalizedResourceDictionary : System.Windows.ResourceDictionary
  {
    public LocalizedResourceDictionary()
    {
      // Vynucené nastavení jazyka. Tato lokalizace se pak zobrazuje v designeru
      if(System.ComponentModel.DesignerProperties.IsInDesignTool) {
        LangResources.LocalizedStrings.Culture = new System.Globalization.CultureInfo("cs-CZ");
      }
      // 
      Type typeOfRes = typeof(LangResources.LocalizedStrings);
      var properties = from property in typeOfRes.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)
                       where property.PropertyType == typeof(string)
                       select property;

      foreach(PropertyInfo property in properties) {
        string value = (string)property.GetValue(null, null);
        this.Add("ls_"+property.Name, value);
      }
    }
  }
}
